<?php    
    $isset = false;
    if(isset($_POST['mamh']))
    {
        $mamh = $_POST['mamh'];
        
        $sql = "SELECT * FROM monhoc WHERE MAMONHOC = '".$mamh."'";
        $result = mysql_query($sql);
        if(mysql_num_rows($result)!=0){
            $isset = true;
            $row = mysql_fetch_assoc($result);
        }
        
    }
?>
<script type="text/javascript">

    function chon_mh(value)
    {
        var list_id = "";
        $('#loading_').html("<img src='../image/source/loading.gif' />");
        $.ajax({
            url: "quanlymh/ajax_edit.php",
            type: "POST",
            data: "mamh="+value+"&action=get_info",
            
            success: function(result)
            {
                $('#loading_').html("");
            },
            error: function()
            {
                $('#loading_').html("");
            }
        });
    }
</script>

<style>
   .label{background: #247CB9; color: #fff; padding: 5px;}
   .value{width: 350px; background: #FFF2F7; padding: 5px;}
</style>

<div id="function">
    CHỈNH SỬA THÔNG TIN MÔN HỌC
</div>

<div id="left" style="margin-left: 10px; padding: 10px;">
    <form name="chinhsua" method="post" action="">
    <table>
        <tr>
            <td class="label"><center>Nhập Mã MH cần chỉnh sửa</center></td>
        </tr>
        <tr>
            <td  class="value" style="width: 180px;"><center>
                <input type="text" name="mamh" id="chon_mamh" />
            </center></td>
            
            <td><center><input type="submit" value="Chọn" class="s_button" /></center></td>                     
        </tr>
        <tr><td style="width: 20px;"><div id="loading_"></div></td></tr>
    </table> 
    </form>
</div>   


<div id="function_content">
    <form name="edit_info" method="post" action="quanlymh/ajax_edit.php">
    <center><table>
        <tr>    
            <td class="label">Mã MH: &nbsp; </td>
            <td class="value"><input type="text" name="mamh" value="<?php 
                echo ($isset)? $row['MAMONHOC'].'"' : '" disabled="disable"';?> />
            </td>
        </tr>
        <tr>
            <td class="label">Tên MH: </td>
            <td class="value"><input type="text" name="tenmh" value="<?php
                echo ($isset)? $row['TENMONHOC'].'"' : '" disabled="disable"';?> />
            </td>
        </tr>
        <tr>
            <td class="label">TC Lý thuyết: </td>
            <td class="value"><input type="text" name="tclt" value="<?php 
                echo ($isset)? $row['TINCHILYTHUYET'].'"' : '" disabled="disable"';?> />
            </td>
        </tr>
        
        <tr>
            <td class="label">TC Thực hành: </td>
            <td class="value"><input type="text" name="tcth" value="<?php 
                echo ($isset)? $row['TINCHITHUCHANH'].'"' : '" disabled="disable"';?> />
            </td>
        </tr>
        
        <tr>
            <td class="label">Học kỳ: </td>
            <td class="value"><input type="text" name="hocky" value="<?php 
                echo ($isset)? $row['HOCKY'].'"' : '" disabled="disable"';?> />
            </td>
        </tr>
        <tr>
            <td class="label">Khoa: </td>
            <td class="value"><input type="text" name="khoa" value="<?php 
                echo ($isset)? $row['MAKHOA'].'"' : '" disabled="disable"';?> />
        </tr>
        <tr>
            <td class="label">Trạng thái: </td>
            <td class="value"><input type="text" name="trangthai" value="<?php 
                echo ($isset)? $row['TRANGTHAI'].'"' : '" disabled="disable"';?> />
        </tr>
        <tr><td>&nbsp;</td></tr>
        
        <tr>
            <td colspan="2"><center><input type="submit" name="action" value="Chỉnh sửa" <?php echo ($isset)?'':'disabled="disable"s'; ?> class="s_button" /></center></td>
        </tr>  
    </table></center>
    </form>   
</div>